package com.xb.loan.fund;
import com.xb.loan.fund.common.FundConfig;
import com.xb.loan.fund.task.CashEncashTask;
import com.xb.loan.util.SpringHelper;
import com.xb.loan.util.log.DefaultLoggerFacotry;
import com.xb.loan.util.log.LogFormatUtil;
import com.xb.loan.util.qrtz.TaskScheduleManager;
import org.slf4j.Logger;

public class StartFund {
	
	private static final Logger logger = DefaultLoggerFacotry.getLogger(StartFund.class);

	public static void main(String[] args) {
		logger.info(LogFormatUtil.getFormatMsg(new String[]{"module", "msg"},
				new Object[]{"fund", "prepare to start..."}));
		try{
			SpringHelper.init("classpath:/spring/applicationContext.xml");
			
			TaskScheduleManager taskManager = SpringHelper.getBean("taskScheduleManager");
			FundConfig config = SpringHelper.getBean("fundConfig");
			taskManager.shedule("fund_encash", CashEncashTask.class, config.getEncashCron(), null);
			
		}catch(Exception e){
			logger.error(LogFormatUtil.getFormatMsg(new String[]{"module", "msg"},
					new Object[]{"fund", "has some problem in the start..."}), e);
		}
		logger.info(LogFormatUtil.getFormatMsg(new String[]{"module", "msg"},
				new Object[]{"fund", "start successfully..."}));
	}

}
